package pro.bbs.server.web;

import com.yy.pojo.bbs.TPost;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import pro.bbs.server.service.ITPostService;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 论坛帖子相关控制类
 * </p>
 *
 * @author 杨阳
 * @since 2017年10月12日
 */
@Api(value = "论坛帖子相关控制类", tags = {"包含发帖，回帖等操作"})
@RestController
@RequestMapping("/post")
public class BBSServerTPostController {

    @Resource(name = "iTPostService")
    private ITPostService iTPostService;

    @ApiOperation(value = "查询出所有帖子，以发贴时间倒序排序", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "当前页", name = "page", required = true, paramType = "query"),
            @ApiImplicitParam(value = "每页显示记录数", name = "limit", required = true, paramType = "query"),
            @ApiImplicitParam(value = "查询帖子标题", name = "title", example = "JAVA", paramType = "query"),
            @ApiImplicitParam(value = "查询帖子内容", name = "content", example = "如何发帖", paramType = "query"),
            @ApiImplicitParam(value = "map类型参数，但不在这里传", name = "params", paramType = "query")
    })
    @RequestMapping(value = "/getAllPosts", method = RequestMethod.POST)
    public List<TPost> getAllPosts(@RequestParam Map<String, Object> params) {
        return iTPostService.getAllPost(params);
    }

}
